package com.atxwq.shop.manager.controller;

import com.atxwq.shop.manager.serivce.FileUploadService;
import com.atxwq.shop.model.vo.common.Result;
import com.atxwq.shop.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description 文件（头像）上传
 * @Date 2025/5/10 20:45
 * @Created by 12336
 */

@RestController
@RequestMapping("/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @PostMapping("/fileUpload")
    public Result fileUpload(@RequestParam("file") MultipartFile file ){
        //1.获取上传的文件
        //2.调用service方法
        String url = fileUploadService.upload(file);

        return Result.build(url, ResultCodeEnum.SUCCESS);
    }

}
